package edu.mtu.citizenscience.cs.notepad.model;

import java.util.Date;

import com.openswimsoftware.orm.model.Model;
import com.openswimsoftware.orm.model.annotation.Child;
import com.openswimsoftware.orm.model.annotation.Children;
import com.openswimsoftware.orm.model.list.ModelList;

import android.content.Context;

import edu.mtu.citizenscience.cs.notepad.model.note.ModelImage;
import edu.mtu.citizenscience.cs.notepad.model.note.ModelLocation;
import edu.mtu.citizenscience.cs.notepad.model.note.ModelRecording;
/**
 * @author Corbin Uselton <corbinu@cwuselto@mtu.edu>
 * @copyright (c) 2012 MichiganTech <http://www.mtu.edu>
 * @since 1.0
 * 
 * Model of an note in the app DB
 * has a uploaded indicator, message, title,
 * images, location, and recording
 */
public class ModelNote extends Model<ModelNote> {
	// reference var for passing note model id between activities
	public static final String NOTE_ID = "NOTE_ID";
	
	// whether the note has been uploaded or not
	private boolean uploaded;
	// date time the note was last updated
	private Date date;
	// the note title
	private String title;
	// the note message
	private String message;
	
	// the note has 0->Many images
	@Children(modelType = ModelImage.class)
	private ModelList<ModelImage> images;
	
	// the note has a child location model
	@Child
	private ModelLocation location;
	// the note has a child recording model
	@Child
	private ModelRecording recording;
	
	/**
	 * Create the note model
	 * 
	 * @param   context - Context - context for model operations
	 * @return	void
	 */
	public ModelNote(Context context) 
	{
		super(context, ModelNote.class);
	}

	/**
	 * Create the note model
	 * 
	 * @param   context - Context - context for model operations
	 * @param	id - long - the model id to load from the DB
	 * @return	void
	 */
	public ModelNote(Context context, long id) 
	{
		super(context, ModelNote.class, id);
	}
	
	/**
	 * Get the note is uploaded
	 * 
	 * @param   void
	 * @return	boolean - whether the note was uploaded
	 */
	public boolean isUploaded() 
	{
		// make sure the model is loaded
		this.load();
		
		return uploaded;
	}

	/**
	 * Set the report is uploaded
	 * 
	 * @param   uploaded - boolean - whether the note was uploaded
	 * @return	void
	 */
	public void setUploaded(boolean uploaded) 
	{
		// mark the model as updated
		this.updated = true;
		
		this.uploaded = uploaded;
	}

	/**
	 * Get the date the note was last updated
	 * 
	 * @param   void
	 * @return	Date - the date the note was last updated
	 */
	public Date getDate() 
	{
		// make sure the model is loaded
		this.load();
		
		return date;
	}

	/**
	 * Set the date the note was last updated
	 * 
	 * @param   date - Date - the date the note was last updated
	 * @return	void
	 */
	public void setDate(Date date) 
	{
		// mark the model as updated
		this.updated = true;
		
		this.date = date;
	}

	/**
	 * Get the note title
	 * 
	 * @param   void
	 * @return	String - the notes title
	 */
	public String getTitle() 
	{
		// make sure the model is loaded
		this.load();
		
		return title;
	}

	/**
	 * Set the note title
	 * 
	 * @param   title - String - the notes title
	 * @return	void
	 */
	public void setTitle(String title) 
	{
		// mark the model as updated
		this.updated = true;
		
		this.title = title;
	}

	/**
	 * Get the note message
	 * 
	 * @param   void
	 * @return	String - the notes message
	 */
	public String getMessage() 
	{
		// make sure the model is loaded
		this.load();
		
		return message;
	}

	/**
	 * Set the note message
	 * 
	 * @param   message - String - the notes message
	 * @return	void
	 */
	public void setMessage(String message) 
	{
		// mark the model as updated
		this.updated = true;
		
		this.message = message;
	}

	/**
	 * Get the note's images
	 * 
	 * @param   void
	 * @return	ModelList<ModelImage> - list of note images
	 */
	public ModelList<ModelImage> getImages() 
	{
		// make sure the model is loaded
		this.load();
		
		return images;
	}

	/**
	 * Set the note's images
	 * 
	 * @param   image - ModelList<ModelImage> - list of note images
	 * @return	void
	 */
	public void setImages(ModelList<ModelImage> images) 
	{
		// mark the model as updated
		this.updated = true;
		
		this.images = images;
	}

	/**
	 * Get the note's location
	 * 
	 * @param   void
	 * @return	ModelLocation - the notes location
	 */
	public ModelLocation getLocation() 
	{
		// make sure the model is loaded
		this.load();
		
		return location;
	}

	/**
	 * Set the note's location
	 * 
	 * @param   location - ModelLocation - the notes location
	 * @return	void
	 */
	public void setLocation(ModelLocation location) 
	{
		// mark the model as updated
		this.updated = true;
		
		this.location = location;
	}

	/**
	 * Get the note's recording
	 * 
	 * @param   void
	 * @return	ModelRecording - the notes recording
	 */
	public ModelRecording getRecording() 
	{
		// make sure the model is loaded
		this.load();
		
		return recording;
	}

	/**
	 * Set the note's recording
	 * 
	 * @param   recording - ModelRecording - the notes recording
	 * @return	void
	 */
	public void setRecording(ModelRecording recording) 
	{
		// mark the model as updated
		this.updated = true;
		
		this.recording = recording;
	}

}
